<template>
	<view>
		<u-navbar back-text="返回" :title="$route.query.title"></u-navbar>

		<view>
			<u-tabs name="cate_name" count="cate_count" :list="tabList" :is-scroll="true" bg-color="#fff"
				:current="current" @change="change" vertical>
				<view v-for="(item, index) in tabList" :key="index">
					<text v-if="current === index">{{ item.name }} 的内容</text>
				</view>
			</u-tabs>
			
			<view class="wrap">
				<u-section title="预约时间" line-color="#0079FE" :right="false"></u-section>
				<u-grid :col="2">
					<u-grid-item v-for="(item, index) in gridList" :key="item.index">
						<view class="grid-text">{{ item.startTime}} - {{ item.endTime}}</view>
						<view v-if="item.count">
							<u-button type="primary" @click="goToMessage(item)">
								{{ item.status}}
								<text>({{ item.count }})</text>
							</u-button>
						</view>
						<view class="gray" v-else>
							<u-button type="primary" @click="goToMessage(item)">
								{{ item.status}}
							</u-button>
						</view>
					</u-grid-item>
				</u-grid>

				<u-section title="排队时间" line-color="#0079FE" :right="false"></u-section>
				<u-grid :col="2">
					<u-grid-item v-for="(item, index) in lineList" :key="item.index">
						<view class="grid-text">{{ item.startTime}} - {{ item.endTime}}</view>
						<view v-if="item.count">
							<u-button type="primary" @click="goToMessage(item)">
								{{ item.status}}
								<text>({{ item.count }})</text>
							</u-button>
						</view>
						<view class="gray" v-else>
							<u-button type="primary" @click="goToMessage(item)">
								{{ item.status}}
							</u-button>
						</view>
					</u-grid-item>
				</u-grid>
			</view>
			<u-top-tips ref="uTips"></u-top-tips>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadStatus: 'loadmore',
				flowList: [],
				scrollTop: 0,
				lineList: [
					{
						startTime:'9:00',
						endTime: '14:00',
						status:'可排队',
						count: 3
					},
					{
						startTime:'14:00',
						endTime: '18:30',
						status:'可排队',
						count: 8
					}
				],
				gridList: [
					{
						startTime:'9:00',
						endTime: '9:30',
						status:'已超时',
					},
					{
						startTime:'9:30',
						endTime: '10:00',
						status:'已超时',
					},
					{
						startTime:'10:00',
						endTime: '10:30',
						status:'可预约',
						count: 3
					},
					{
						startTime:'10:00',
						endTime: '11:30',
						status:'预约已满',
					},
					{
						startTime:'11:30',
						endTime: '12:00',
						status:'预约已满',
					},
					{
						startTime:'14:00',
						endTime: '14:30',
						status:'预约已满',
					},
					{
						startTime:'14:30',
						endTime: '15:00',
						status:'预约已满',
					},
					{
						startTime:'15:00',
						endTime: '15:30',
						status:'预约已满',
					},
					{
						startTime:'15:30',
						endTime: '16:00',
						status:'预约已满',
					},
					{
						startTime:'16:00',
						endTime: '16:30',
						status:'预约已满',
					},
				],
				tabList: [{
						cate_name: '03/25',
						title: '今天'
					},
					{
						cate_name: '03/26',
						title: '周二'
					},
					{
						cate_name: '03/27',
						title: '周三'
					},
					{
						cate_name: '03/28',
						title: '周四'
					},
					{
						cate_name: '03/29',
						title: '周五'
					},
					{
						cate_name: '03/30',
						title: '周六'
					},
					{
						cate_name: '04/01',
						title: '周日'
					},
				],
				current: 0,
				list: [{
						title: '常规预约/排队表',
						image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
					},
					{
						title: '一线员工晚间烫染排队表（限分公司员工）',
						image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
					},
				]
			}
		},
		methods: {
			/**
			 * 跳转到预约信息页面
			 */
			goToMessage(item) {
				if(item.status === '已超时'){
					this.$refs.uTips.show({
						title: '该时段已超时，不可预约！',
						type: 'warning',
						duration: '3000'
					})
				}else if(item.status === '预约已满'){
					this.$refs.uTips.show({
						title: '该时段预约名额已满，不可预约！',
						type: 'warning',
						duration: '3000'
					})
				}else {
					this.$tab.navigateTo(`/pages/work/message`)
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.wrap {
		margin: 0 20rpx;
		.u-section {
			margin-top: 40rpx;
		}
		
		.u-grid {
			margin-top: 20rpx;
		}
		
		.grid-text {
			margin-bottom: 10rpx;
			font-weight: bold;
		}
		
		.u-size-default {
			height: 60rpx;
			width: 280rpx;
		}
		
		.gray{
			.u-btn--primary {
				color: #000 !important;
				background-color: $uni-bg-color-hover !important;
			}
		}
	}
</style>